package hr.fer.apr.ht41337.lab1;

public class Glavni {

	public static void main(String[] args) {
		
		Matrica A = Matrica.read("A.dat");
		Matrica b = Matrica.read("b.dat");
		try{
			A.LUDecomposition();
			System.out.println("Matrica A nakon LU dekompozicije:");
			A.print();
			Matrica y = A.substitutionForward(b);
			System.out.println("Matrica y:");
			y.print();
			Matrica x = A.substitutionBackward(y);
			System.out.println("Rjesenje sustava:");
			x.print();
			x.print("xLU.dat");
		} catch(Exception e){
			System.out.println(e.getMessage());
		}
		
		A = Matrica.read("A.dat");
		b = Matrica.read("b.dat");
		try{
			Matrica p = A.LUPDecomposition();
			System.out.println("Matrica A nakon LUP dekompozicije:");
			A.print();
			System.out.println("Matrica b nakon zamjene redaka:");
			b = p.times(b);
			b.print();
			Matrica y = A.substitutionForward(b);
			System.out.println("Matrica y:");
			y.print();
			Matrica x = A.substitutionBackward(y);
			System.out.println("Rjesenje sustava:");
			x.print();
			x.print("xLUP.dat");
		} catch(Exception e){
			System.out.println(e.getMessage());
		}
	}

}
